package com.wing.product.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 产品订单
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("pro_product_order")
public class ProductOrder extends BaseEntity<ProductOrder> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Type implements IEnum<Integer> {

        /**
        * 采购
        */
        purchase(0,"采购"),
        /**
        * 租凭
        */
        lease(1,"租凭");

        private int code;
        private String desc;

        Type(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum Status implements IEnum<Integer> {

        /**
         * 未支付
         */
        unpaid(0,"未支付"),
        /**
         * 已付定金
         */
        depositPaid(1,"已付定金"),
        /**
         * 已发货
         */
        shipped(2,"已发货"),
        /**
         * 已完成
         */
        complete(3,"已完成"),
        /**
         * 已关闭
         */
        closed(4,"已关闭"),
        /**
         * 已取消
         */
        cancel(5,"已取消"),
        /**
         * 定金退款中
         */
        refunding(6, "定金退款中"),
        /**
         * 定金已退款
         */
        refunded(7,"定金已退款"),
        /**
         * 定金退款异常
         */
        refundAbnormal(8,"定金退款异常");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 订单编号
     */
    private String sn;

    /**
     * 商品描述
     */
    private String title;

    /**
     * 类型
     */
    private Type type;

    /**
    * 类型描述
    */
    @TableField(exist = false)
    private String typeDesc;

    public String getTypeDesc() {
        return type == null ? null : type.getDesc();
    }

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 定金
     */
    private BigDecimal deposit;

    /**
     * 订单金额
     */
    private BigDecimal amount;

    /**
     * 支付定金二维码
     */
    private String qrCode;

    /**
     * 订单过期时间
     */
    private LocalDateTime expiredTime;

    /**
     * 入驻企业ID
     */
    private Long companyId;

    /**
     * 是否同步至企业端
     */
    private Boolean isSyn;

    /**
     * 确认尾款
     */
    private Boolean confirmFinalPayment;

    /**
     * 联系人
     */
    private String contact;

    /**
     * 联系人电话
     */
    private String contactPhone;

    /**
     * 联系地址
     */
    private String address;

    /**
     * UUID
     */
    private String uuid;

}
